home *** CD-ROM | disk | FTP | other *** search
/ The Arsenal Files 6 / The Arsenal Files 6 (Arsenal Computer).ISO / business / hap101.zip / HAP.DOC < prev    next >
Text File  |  1996-01-18  |  45KB  |  1,142 lines

  1.  !!!Check the file CATALOG.DOC for great prices on home automation products!!!
  2.  
  3.  
  4.  
  5.  
  6.  
  7.                      Precision Systems
  8.                      HAP
  9.  
  10.                      Excellence in Home Automation
  11.  
  12.  
  13.  
  14.  
  15.  
  16.   ----------------------------------------------------------------------
  17.   Introduction
  18.   ----------------------------------------------------------------------
  19.   If you think about it, almost all computer applications do a similar
  20.   thing:  create display or printed output based on user input.  You are
  21.   confined to the world as defined by the box sitting on your desk.
  22.  
  23.   A home automation system is a whole different angle on the use of the
  24.   computer, in that your computer now interacts with you in YOUR world.
  25.  
  26.   Imagine, sitting down for dinner, and pressing one button to set up the
  27.   house for a nice, romantic dinner.  The lights come down to a nice mood
  28.   setting, the TV turns off, the stereo system plays a nice classical CD,
  29.   the phone ringers are disabled, the drapes slide closed, and the ceiling
  30.   fan turns on at 50% power, if it is warm inside.  This is only scratching
  31.   the surface of the things that can be done when you use a computer to
  32.   automate the features in your home.
  33.  
  34.   We invite you to explore this document and software, in hopes that you
  35.   will find it invaluable to you and your home!
  36.  
  37.   ----------------------------------------------------------------------
  38.   Disclaimer
  39.   ----------------------------------------------------------------------
  40.  
  41.   This software was released by Precision Systems 1/1/96. I encourage you
  42.   to copy and distribute this SHAREWARE VERSION of the software as you
  43.   wish, so long as it remains intact with this documentation and all other
  44.   supplied files in their unmodified form.  PRECISION SYSTEMS WILL NOT BE
  45.   RESPONSIBLE FOR ANY LOSSES INCURRED FROM THE USE OF THIS SOFTWARE.  USE
  46.   OF THIS SOFTWARE INDICATES ACCEPTANCE OF THESE TERMS.
  47.  
  48.   Now that that's over with.......
  49.  
  50.   ----------------------------------------------------------------------
  51.   HAP History
  52.   ----------------------------------------------------------------------
  53.   Recently, I was browsing through some on-line magazines, and encountered
  54.   an article regarding X-10 home automation products.  I had heard of the
  55.   stuff before, and even tinkered with it, but never realized the full
  56.   potential that it has.  I predict a proliferation of home automation
  57.   products in the near future.  I have created this package as a start for
  58.   a more complete system, so expect it to be updated frequently.  I will
  59.   put in a plug for the registered version here.  It is not limited, and
  60.   comes with the TW-523 module and cables to get you started.
  61.  
  62.   ----------------------------------------------------------------------
  63.   How to get started with home automation
  64.   ----------------------------------------------------------------------
  65.   It is possible to get started without much investment.  I spent around
  66.   $100 to get remote control of the lights in my living room, including
  67.   full dimming capabilities for all lights.  This included a two-button
  68.   keychain remote with receiver, and a large remote capable of controlling
  69.   16 modules.  I spent about 2 hours hooking it all up.  Check out the
  70.   file CATALOG.DOC for special package deals on startup kits.
  71.  
  72.   A basic system consists of several different items, including wall
  73.   switches, remotes, plug in modules, etc.  Transmitters talk to the
  74.   other units over the power lines, via quick pulses when the AC cycle
  75.   is near the 0 voltage position.  Each switch or module has a house
  76.   code, and a unit code.  There are 16 different house codes and 16
  77.   different unit codes, allowing for a maximum of 256 different codes.
  78.  
  79.   Adding a computer to the equation only requires the addition of a
  80.   plug in module that also attaches to your computer.  Software, like
  81.   this software, then becomes the link between your computer and your
  82.   house.
  83.  
  84.   ----------------------------------------------------------------------
  85.   X10 Components
  86.   ----------------------------------------------------------------------
  87.   This section briefly describes some of the components that are available
  88.   for the X10 system.  More are available, but the following units are the
  89.   most common.  All of these items are available from us at mail-order
  90.   prices in the CATALOG.DOC supplied with this package.
  91.  
  92.   Wall Switch -
  93.     This unit directly replaces your existing toggle switch that is built
  94.     into the wall.  Units are available for 3-way wiring also.  You get
  95.     the added benefit of dimming capability to the lights that are
  96.     connected to the switch.  The dimming function is not available on the
  97.     standard wall switches, but they respond to the DIM and BRIGHT commands
  98.     sent from X10 transmitters.  These units also respond to the ALL UNITS
  99.     OFF command, and the ALL LIGHTS ON command.
  100.  
  101.   Lamp Module -
  102.     This unit plugs into the wall, and you plug a lamp into the unit.
  103.     It is similar to the wall switch in functionality, but there is no
  104.     button on it.  However, if you want to turn the lamp on, the unit
  105.     will sense you turning it on and activate the module.
  106.  
  107.   Appliance Module -
  108.     This unit is similar to the lamp module, but does not support the
  109.     dimming capabilities.  This is good for TVs, radios, popcorn makers,
  110.     etc.  These units respond to the ALL UNITS OFF command, but not the
  111.     ALL LIGHTS ON command.
  112.  
  113.   PowerFlash Module -
  114.     This unit was originally designed as an interface to existing
  115.     home security systems, but functions nicely as a way to enable
  116.     non-X10 units to send X10 codes.
  117.  
  118.   Universal Module -
  119.     This unit is the complement to the PowerFlash Module, in that it
  120.     receives X10 signals, and closes a relay circuit when it's code is
  121.     received.  The Universal Modules also includes a chime, so is nice
  122.     in conjunction with motion sensors to let you know when someone is
  123.     approaching the house.
  124.  
  125.   TW-523 Interface -
  126.     This is the unit that connects your computer to the X10 system.  It
  127.     is bidirectional (sends and receives X10 signals) and is the
  128.     interface used in all bidirectional X10 home automation systems.
  129.  
  130.   Many more nifty devices are available.  They are covered in the catalog.
  131.  
  132.   ----------------------------------------------------------------------
  133.   Other Components
  134.   ----------------------------------------------------------------------
  135.   This registed version of this program is capable of talking to your
  136.   infra-red controlled equipment.  For instance, your VCR, stereo, TV,
  137.   etc. can be under control of your computer to provide the functionality
  138.   listed in the 'home automation uses' section of this documentation.
  139.   For this to happen, you will need to obtain the following components,
  140.   of course available in our supplied catalog CATALOG.DOC.
  141.  
  142.   All for One remote -
  143.     A product designed as a remote control to control all of your
  144.     audio/video equipment, has all current equipment pre-programmed into
  145.     it.  When new equipment comes along, it is reprogrammable via a
  146.     computer interface built into the remote.  The nice thing about this,
  147.     is that the computer interface can be attached to a PC so that the PC
  148.     can 'press buttons' on the remote.  An exceptional product.
  149.  
  150.     I velcro'd my remote to the side of the PC, for a nice, integrated look.
  151.  
  152.   All for One remote to PC interface cable -
  153.     This is the cable required to attach the remote to your PC.  It connects
  154.     to a serial port.
  155.  
  156.   Powermid remote extender -
  157.     This is needed if the PC is not in direct visual range of the equipment
  158.     you wish to control.  It monitors for infra-red signals and transmits
  159.     them to a receiver unit via RF (radio), then converts them back to
  160.     infrared signals.  Your PC can then talk to your audio-video equipment
  161.     from any room in the house.  These are also nice for controlling your
  162.     equipment from the bedroom, etc.  Multiple transmitters are allowed
  163.     to be in the system.
  164.  
  165.   Sound Card -
  166.     These are useful to add speech to your system.  I found that the most
  167.     effective use of these is to use the SHELL command to shell to DOS
  168.     and play a .WAV file.  We are currently starting to create a library
  169.     of .WAV files that are useful for home automation.  Check our BBS for
  170.     the latest stuff.
  171.  
  172.   ----------------------------------------------------------------------
  173.   Business Opportunity
  174.   ----------------------------------------------------------------------
  175.   After getting this software running and automating my house just a
  176.   little bit, I have sold several systems to my friends just by 'showing
  177.   off' my system.  It is easy to sell, because the pieces are inexpensive
  178.   and the effect and convenience is outstanding.
  179.  
  180.   Home automation service and products are a natural to sell along with
  181.   home security systems, home theater, central vacuum, etc.
  182.  
  183.   ----------------------------------------------------------------------
  184.   Home Automation Uses
  185.   ----------------------------------------------------------------------
  186.   As I am sure I am not the first to develop some of these ideas, I will
  187.   not try to take credit for them.  Here are some of the things I am doing
  188.   with my home - some of them are actually implemented, some of them I
  189.   have not been able to afford to construct yet, but most are possible
  190.   with this software package combined with the appropriate hardware.
  191.  
  192.   Mood setting is the most significant use of this software combined with
  193.   home automation hardware.  Instead of having control over individual
  194.   lights or equipment, I have found that there are several standard
  195.   configurations that the house ends up in.  Visualize some of the
  196.   following scenarios:
  197.  
  198.     Button 1, VCR viewing mode
  199.     --------------------------
  200.     In my home, I can press button 1 on my remote to 'set up the house'
  201.     for watching a movie.  All I have to do is insert the movie into the
  202.     VCR, sit down, and press button 1,  which does the following:
  203.  
  204.     1)  Turn the TV on, turn the volume all the way down (I prefer to
  205.     pipe the sound through the stereo), and set it to channel 04.
  206.  
  207.     2)  Turn the stereo on, set it so that is is using the VCR as an
  208.     input, and set the volume to 30% (a nice starting volume).
  209.     Also turn on and setup any home theater equipment.
  210.  
  211.     3)  If it is summer, set the ceiling fan on 50% for a gentle breeze.
  212.  
  213.     4)  My house does not yet have automatic draperies, but the system
  214.     could close the drapes.
  215.  
  216.     5)  If it is dark outside, set the living room lights to 10%,
  217.     otherwise turn them off.  Also dim or turn off any other lights
  218.     that may affect the viewing area.  When setting the lights,
  219.     bring them down slowly for a high-tech effect.
  220.  
  221.     Button 1 again, VCR break mode
  222.     ------------------------------
  223.     This is a nice touch to impress your guests, never mind the convenience!
  224.  
  225.     1)  Stop the VCR
  226.  
  227.     2)  Set stereo to 15% volume, tune in the local classical music
  228.     station (always makes good intermission music)
  229.  
  230.     3)  Bring the living room lights up to about 50%.
  231.  
  232.     4)  Bring all lights on the way to the bathrooms (including the
  233.     bathrooms) up to 70%.  I use 70% so that you don't blast your
  234.     guests eyes out.
  235.  
  236.     5)  Start the popcorn maker, and maybe even pour a glass of wine.
  237.     (Yes, this is possible)
  238.  
  239.     Button 1 again, VCR resume mode
  240.     -------------------------------
  241.     I think you get the idea - set the house up like it was when the
  242.     VCR mode was first started, and start the VCR again.
  243.  
  244.  
  245.     Button 1 off, end VCR mode
  246.     --------------------------
  247.     1)  Turn off the TV
  248.  
  249.     2)  Set the stereo to play a nice evening CD (but only if it is
  250.     actually evening)
  251.  
  252.     3)  Bring the lights up some, to 70%.
  253.  
  254.  
  255.     Button 2, Romantic Dinner mode
  256.     ------------------------------
  257.     1)  Turn off the TV if it is on.
  258.  
  259.     2)  Set the stereo to play either a selected radio station
  260.     or CD, at 30% volume
  261.  
  262.     3)  Start the fireplace (I don't have one, but my dad has a nifty
  263.     gas fireplace that you simply use a switch to turn on)
  264.  
  265.     4)  Set the lights over the dining room table to 20%
  266.  
  267.     5)  Pour a couple of glasses of wine
  268.  
  269.     6)  Disable the telephones
  270.  
  271.     Button 3, Sleep mode
  272.     --------------------
  273.     1)  Turn on the electric blanket (this could also happen
  274.     automatically at a pre-selected time)
  275.  
  276.     2)  Turn all units in the house off, except in the bedrooms
  277.  
  278.     3)  Make sure the garage door is closed
  279.  
  280.     4)  Arm the alarm system
  281.  
  282.     5)  Shell to DOS and play a WAV file that says 'Goodnight, Everybody'.
  283.  
  284.     Button 4 off, Home unoccupied
  285.     -----------------------------
  286.     Install an in-wall transmitter near the front door to activate this
  287.     mode, and the home occupied mode.
  288.  
  289.     The system could know when to expect you back based on your schedule,
  290.     and warm up the house for you by turning the wall heaters on.  At
  291.     night, lights in the house can go on and off for security.
  292.  
  293.     When you arrive home at dark, the outside porch light would be on to
  294.     welcome you home!
  295.  
  296.     Button 4 on, Home occupied
  297.     --------------------------
  298.     When you come home, press the occupied button to set the lighting
  299.     according to time of day, turn on some nice background music, etc.
  300.  
  301.  
  302.     Event scheduling is another way to automate your household.  A sequence
  303.     for weekday wake-up might be:
  304.  
  305.     1)  If it is a weekend or a holiday, skip this sequence.
  306.     2)  At 6:00AM, turn the stereo on a mellow station at 30% volume, and
  307.     also shell to DOS and play a 'Good Morning' .WAV file.
  308.     3)  If the motion sensor in the living room does not detect your
  309.     presence after a few minutes, change the radio station to
  310.     something more obnoxious- perhaps a liberal talk show.  Increase
  311.     the volume to 50%.
  312.     4)  Start the coffee pot.
  313.     5)  Open the drapes in the house to brighten up the morning.
  314.  
  315.   Have you ever spent an hour programming your VCR to record your three
  316.   favorite shows, only to have it erased the next day when the power
  317.   flashes for 30 seconds?  HAP can be programmed to start the VCR also.
  318.   The programming is then on diskette or hard disk, safe from power
  319.   outages.
  320.  
  321.   We are just scratching the surface here.  The possibilities seem endless.
  322.   Let your imagination go!
  323.  
  324.   More ideas:
  325.  
  326.     - How about a large CD jukebox that can hold your entire CD collection.
  327.       Create a database of all CDs and songs.  Then you can ask the system
  328.       to play random selections of - say - good exercise music.  This can
  329.       be done on a small scale with the existing CD changers available.
  330.  
  331.     - Install a motion sensor outside.  Also install a camera outside, and
  332.       a P.I.P. (Picture In Picture) system on your TV.  When someone walks
  333.       up, have the system activate a chime, turn on the TV if it is not on,
  334.       and connect the outside camera to the P.I.P. display on the TV so you
  335.       can see who is coming up.
  336.  
  337.     - Automate your lawns irrigation system.  X10 modules are available
  338.       that do this nicely.  Available also are moisture sensors that will
  339.       tell the system when the lawn needs to be watered.  This works nice
  340.       in my area, because we are only allowed to water on odd numbered
  341.       days, and never if the day is the 31st.  With a normal irrigation
  342.       controller, I am having to change the programming every month.
  343.  
  344.     - Create an intelligent system that is intuitive.  For example, every
  345.       evening you like to come home and watch the news.  The system could
  346.       learn this, and automatically set up the TV when the news comes on.
  347.       This type of idea could be taken a long ways, but might border on
  348.       annoying at times.
  349.  
  350.  
  351.  
  352.   ------------------------------------------------------------------------
  353.   System Requirements
  354.   ------------------------------------------------------------------------
  355.   - MS-DOS computer.  Yes, it needs to be dedicated.  Fortunately, the
  356.     software should run nicely on that 4.77 mhz 8086 XT sitting in the
  357.     closet under your 1970s white polyester leisure suit.  This makes it
  358.     cheaper than buying some of the home control units that are available,
  359.     and gives you an opportunity to take the suit to the dump.  Hook up
  360.     that old amber monochrome monitor that glitches now and then, load
  361.     this software, and Voila!  Instant home automation.
  362.  
  363.   - BI-DIRECTIONAL parallel port for the TW-523 interface (listed next).
  364.  
  365.   - X10 TW-523 bidirectional interface, to send and receive the X-10
  366.     commands.
  367.  
  368.   - RS-232 serial port, if you want infrared control.  You will also
  369.     need the one-for-all remote, and interface cable.
  370.  
  371.   We chose not to write the first version in Windows, as the system
  372.   requirements are, of course, much more demanding (and expensive).  If
  373.   there is sufficient demand, I will create a Windows version.
  374.  
  375.   ------------------------------------------------------------------------
  376.   Availability of Source Code
  377.   ------------------------------------------------------------------------
  378.   I am undecided on this issue.  What good would it do you if you
  379.   made a bunch of changes, then wanted to update to the latest version?
  380.   I am willing to negotiate the issue.
  381.  
  382.   This software is programmed in Borland's excellent C++ compiler.
  383.  
  384.   ---------------------------------------------------------------------
  385.   Registration
  386.   ---------------------------------------------------------------------
  387.   Registration of this software encourages its further development and
  388.   perfection.  The registered version entitles you to the following:
  389.  
  390.   ->  Fully capable and up-to-date version sent to you, along with a
  391.       printed copy of the documentation.
  392.  
  393.   ->  Access to upgrades via a special account on our BBS.
  394.  
  395.   ->  Priority on bug (what bugs..) fixes and enhancement suggestions.
  396.  
  397.   How much?
  398.  
  399.   Registration for HAP is $99.95.  Registration INCLUDES a TW-523
  400.   powerline interface, registered HAP-BASIC software, and cables 
  401.   necessary for connection of your computers parallel port to the TW-523.
  402.  
  403.   Check the enclosed CATALOG.DOC for further information!
  404.  
  405.   ---------------------------------------------------------------------
  406.   How to contact us
  407.   ---------------------------------------------------------------------
  408.   The place you will most likely get a timely response is our support
  409.   BBS, 'Metropolis'.
  410.  
  411.             Precision Systems
  412.             P.O. Box 7796
  413.             Bend, OR 97708
  414.  
  415.             (541) 330-0728
  416.  
  417.             BBS  Metropolis!     (541) 389-5404 <=14400
  418.  
  419.   ---------------------------------------------------------------------
  420.   Installation and Configuration
  421.   ---------------------------------------------------------------------
  422.   No special procedures are necessary for installation, as long as the
  423.   TW-523 is installed.  Simply copy the files that accompany this document
  424.   into a subdirectory.  We recommend C:\HAP.
  425.  
  426.   -----------------------------------------------------------------------
  427.   Getting Started
  428.   -----------------------------------------------------------------------
  429.   Consider purchasing a startup package.  There are several versions,
  430.   ranging from a basic equipment list, to a full package for infrared
  431.   control.  Of course, the supplied CATALOG.DOC will help you with this.
  432.  
  433.   After obtaining and installing the TW-523 interface, and/or the IR
  434.   interface, try some of the supplied .HAP sample programs.
  435.  
  436.   To start HAP-BASIC, simply start the program with the .HAP script as
  437.   a parameter:
  438.  
  439.   HAP CONTROL.HAP
  440.  
  441.   Optional parameters are /Ix, to change the serial port for the infra-red
  442.   controller, and /Tx, to change the parallel port for the TW-523 interface.
  443.   Defaults are COM1 for the infra-red controller, and LPT1 for the TW-523
  444.   interface.  For example:
  445.  
  446.   HAP TEST.HAP /I2 /T3
  447.  
  448.   This will run the automation script called TEST.HAP, using com2 for the
  449.   IR interface, and lpt3 for the TW-523 interface.
  450.  
  451.   We encourage you to upload your .HAP programs to our BBS to share with
  452.   others.  The BBS number is (541) 389-5404.
  453.  
  454.   -----------------------------------------------------------------------
  455.   Defining Modules
  456.   -----------------------------------------------------------------------
  457.   Modules are defined early in the program to simplify the organization of
  458.   your home automation system.  After the modules are defined, they can
  459.   be called by name, instead of remembering their specific unit codes
  460.   or IR commands.
  461.  
  462.   Currently, the only module type supported is 'X10'.
  463.   Example:
  464.  
  465.     define module MBLIGHT    type X10 { LampModule E16 }
  466.  
  467.   The above example defines a module called MBLIGHT (Master Bedroom Light?)
  468.   that is an X10 lamp module addressed at housecode E, unit 16.  Now you
  469.   can access that unit by referencing its name instead of memorizing
  470.   all of the X10 addresses.  For example:
  471.  
  472.     sendcmd MBLIGHT, "ON"
  473.     sendmcmd MBLIGHT, "DIM", 10
  474.  
  475.   The supported X10 module types are:
  476.  
  477.     - WallSwitch
  478.     - LampModule
  479.     - ApplianceModule
  480.  
  481.   -----------------------------------------------------------------------
  482.   Defining Events
  483.   -----------------------------------------------------------------------
  484.   Events are an extension to the standard BASIC language, made specifically
  485.   for home automation purposes.  They are used to define something that
  486.   can happen that you would like to process.
  487.  
  488.   An event might be one of the following:
  489.  
  490.       - A button pressed on an X10 controller
  491.       - A time of day
  492.       - Every minute
  493.       - Every hour
  494.  
  495.   An event is defined by placing a 'Define Event' command at the beginning
  496.   of your HAP-BASIC program.  After the 'Define Event', the name of the
  497.   event follows.  The body of the event is thereafter defined.
  498.  
  499.   Example:
  500.  
  501.     define event VCRPLAY
  502.     {
  503.       X10Code A4 ON
  504.     }
  505.  
  506.   The example above would generate an event called VCRPLAY when A4 ON
  507.   is received.
  508.  
  509.   Example:
  510.  
  511.     define event WAKEUP
  512.     {
  513.       Time 17:54-.MTWTF.
  514.     }
  515.  
  516.   The example above would generate an event called WAKEUP at 5:54pm Monday,
  517.   Tuesday, Wednesday, Thursday, Friday, but not Saturday or Sunday.
  518.  
  519.  
  520.   Example:
  521.  
  522.     define event MINUTE
  523.     {
  524.       Every Minute
  525.     }
  526.  
  527.   The example above would generate an event called MINUTE every minute.
  528.   This is handy for doing screen updates in the HAP-BASIC program.
  529.  
  530.   Example:
  531.  
  532.     define event HOUR
  533.     {
  534.       Every Hour
  535.     }
  536.  
  537.   The example above would generate an event called HOUR every hour.
  538.  
  539.   The above examples outline all currently supported event types.  They
  540.   are summarized here:
  541.  
  542.   Every Minute        - generates an event every minute
  543.   Every Hour          - generates an event every hour
  544.  
  545.   Time HH:MM-SMTWTFS  - Generates an event at the specified time on the
  546.             specified days.  If you do not want an event to
  547.             occur on a specific day, replace the letter with
  548.             a period '.'.  Example:  Time 10:15-S.T.T.S would
  549.             generate the event at 10:15 in the morning every
  550.             Sunday, Tuesday, Thursday, and Saturday.
  551.  
  552.   X10Code Hnn mode    - Generates an event when the specified X10 code
  553.             is received by the interface.  Example:
  554.             X10Code E14 ON would generate an event when E14 ON
  555.             is received.
  556.  
  557.   For more thorough examples, refer to the sample .HAP files supplied with
  558.   this package.
  559.  
  560.   -------------------------------------------------------------------------
  561.   The HAP interpreter
  562.   -------------------------------------------------------------------------
  563.   We chose to use a free form interpreter instead of a 'point and click'
  564.   programming interface because it provides more flexibility,  is not
  565.   difficult to learn, and creates a more robust automation system.  For
  566.   instance, it is difficult to express to a 'point and click' interface
  567.   that you want to water your lawn only on odd numbered days, and never
  568.   on the 31st.  A free-form programming language can easily accomplish
  569.   this task with simple modulo math.
  570.  
  571.   Another factor for the decision to use a free form language is you.
  572.   If you are interested in home automation, you are probably the type of
  573.   person that has already spent time tinkering with computer programming.
  574.   When you were 10 years old, you wired a switch to your bed that turned
  575.   your TV on and off, maybe built your own stereo, fixed your mom's blender
  576.   (or took it apart to try), etc.  I am that type of person, and enjoy
  577.   exploring technology.  Odds are, you are the same.
  578.  
  579.   The interpreter is based around the popular programming language 'BASIC'.
  580.   If you have prior experience programming in BASIC, great!  All you need
  581.   to do is learn the extensions supplied that are specific to home
  582.   automation and you are on your way.  If you don't have programming
  583.   experience, fear not.  Sample programs are supplied and you will find
  584.   it easy to follow what is happening and modify it to your needs.
  585.  
  586.   Things to know:
  587.  
  588.   1) The interpreter is integer based, and does not support floating point
  589.      math.
  590.  
  591.   2) The interpreter is not a complete set of BASIC commands, just those
  592.      that we thought appropriate to home automation, plus some extras.
  593.  
  594.   3) If demand for this product exists, we will improve upon the
  595.      functionality of the interpreter.  As it sits now, it should be able
  596.      to handle most needs for home automation.
  597.  
  598.   4) The interface to the X10 TW-523 module is interrupt driven, and
  599.      therefore does not always require attention from your BASIC program.
  600.      The last 100 X10 commands are stored in a buffer and are available
  601.      at any time.
  602.  
  603.   It is beyond the scope of this manual to provide instruction on
  604.   programming methods and theories, but all supported commands and their
  605.   syntax is covered, along with the extensions to the language.
  606.  
  607.   Probably the easiest way to learn this is to start with the sample
  608.   program that is included in this package, COMPLEX.HAP.  Modify it to 
  609.   work with your house.  After that, you should have no problem learning 
  610.   the more advanced commands.  Take your time, and add one thing at a time.
  611.  
  612.   The following commands are supported in the HAP-BASIC interpreter:
  613.  
  614.   PRINT
  615.     Print information to the screen at the current location, and in the
  616.     current colors.
  617.  
  618.     Examples:     PRINT "Hello there, ";name$;"!"
  619.           PRINT " Fourteen plus Three equals ";14+3
  620.  
  621.     A semicolon at the end of the statement will keep the interpreter
  622.     from sending a linefeed/carraige return.
  623.  
  624.     Example:    PRINT "This is a ";
  625.         PRINT "test"
  626.  
  627.         Will result in:     This is a test
  628.  
  629.   INPUT
  630.     Ask user for information.
  631.  
  632.     Examples:   INPUT "Enter your name", name$
  633.  
  634.   REM
  635.     A remark, or comment.  Everything on a line after an REM command is
  636.     ignored.  Comments are useful for making your program more readable.
  637.  
  638.     Example:        REM  This is a comment
  639.  
  640.   IF / THEN
  641.     Conditional processing.  IF a condition is true, THEN do something.
  642.  
  643.     Example:    IF X>10 THEN GOSUB Routine:
  644.  
  645.         If the value of X is greater than 10, then execute the
  646.         subroutine called 'Routine'
  647.  
  648.     Note:       Typical BASIC AND and OR statements are not supported yet.
  649.  
  650.   FOR / TO / NEXT
  651.     Process code several times.
  652.  
  653.     Example:    FOR X = 1 TO 20
  654.             {code to be repeated}
  655.             {many lines can be in between the FOR and NEXT commands}
  656.             PRINT X
  657.         NEXT
  658.  
  659.         This example will print the numbers 1 thru 20.
  660.  
  661.     Note:       STEP as defined in typical BASIC is not supported yet.
  662.  
  663.   GOTO
  664.     Branch execution to another location.
  665.  
  666.     Example:    GOTO Routine:
  667.  
  668.         Execution of the program will be transferred to the code
  669.         beginning at the label 'Routine:'.
  670.  
  671.   GOSUB / RETURN
  672.     Branch execution to a subroutine.
  673.  
  674.     Example:    PRINT "A Rose ";
  675.         GOSUB Routine:
  676.         PRINT "by any other name."
  677.  
  678.         Routine:
  679.         PRINT "is a rose. . . ";
  680.         RETURN
  681.  
  682.         End result of the above code fragment will result in:
  683.  
  684.          A Rose is a rose. . . by any other name.
  685.  
  686.   START
  687.     Specifies the start of the program.  Be sure to place a START command
  688.     AFTER the modules and events have been defined.
  689.  
  690.  
  691.   END
  692.     Specifies the end of the program.  When the interpreter encounters
  693.     the END command, the program finishes.
  694.  
  695.   DIM
  696.     Specify the dimensions of a variable array.
  697.  
  698.     Example:   DIM A$(10)
  699.  
  700.     If you have a need for arrays, you must use the DIM command to
  701.     tell the interpreter what the dimensions of the array are.
  702.  
  703.   CLS
  704.     Clears the screen.
  705.  
  706.   BEEP
  707.     Creates a system beep from the computers built in speaker.
  708.  
  709.   COLOR ff,bb
  710.     Change the system colors.  The first parameter is the foreground color,
  711.     the second is the background color.
  712.  
  713.     Colors:
  714.  
  715.       Black                    0
  716.       Blue                     1
  717.       Green                    2
  718.       Cyan                     3
  719.       Red                      4
  720.       Magenta                  5
  721.       Brown                    6
  722.       White                    7
  723.       Dark Gray                8
  724.       Light Blue               9
  725.       Light Green              10
  726.       Light Cyan               11
  727.       Light Red                12
  728.       Light Magenta            13
  729.       Yellow                   14
  730.       Bright White             15
  731.  
  732.       Note:   Colors 8-15 when specified for background color
  733.           result in blinking text.
  734.  
  735.  
  736.     Example:   COLOR 4,7
  737.            PRINT "This text is red on white"
  738.  
  739.   LOCATE
  740.     Position the cursor at a specific location.
  741.  
  742.     Example:   LOCATE 10,20
  743.  
  744.            This example will move the cursor to row 10, column 20.
  745.  
  746.  
  747.   The following commands are extensions to the BASIC language:
  748.  
  749.   EVENT_CHECK
  750.     Tells the system to check for any events that may have occurred, and
  751.     flags them as active.  Available events can be retrieved by using the
  752.     function 'EVENT_AVAIL(0)'.  Use EVENT_CHECK before using
  753.     'EVENT_AVAIL(0)', or the computer will never test to see if the events
  754.     need to be triggered.
  755.  
  756.     This command should be executed at least every minute, so that timed
  757.     events will be triggered.  What this means is, don't design your event
  758.     processors so that they take more than a minute to execute, or you might
  759.     miss a timed event.
  760.  
  761.     Example:     EVENT_CHECK
  762.          event = EVENT_AVAIL(0)
  763.  
  764.   EVENT_RESET n
  765.     Resets the triggered state of an event after you have processed it.
  766.     Specify the event that you are resetting.
  767.  
  768.     If you don't reset an event, it will indefinitely be active.
  769.  
  770.     Example:    EVENT_CHECK
  771.         event = EVENT_AVAIL(0)
  772.  
  773.         if event = WAKEUP then gosub Wakeup:
  774.  
  775.         Wakeup:
  776.           EVENT_RESET event
  777.           (process event here)
  778.         return
  779.  
  780.   SHELL
  781.     This command will shell an external program, command, or batch file.
  782.  
  783.     Example:  SHELL "DIR"
  784.           SHELL "HELLO.EXE"
  785.           SHELL "COMMAND.COM"
  786.  
  787.     SHELL "COMMAND.COM" gives you a DOS prompt, allowing you to execute
  788.     DOS commands.  To return to the program from a COMMAND.COM shell,
  789.     type EXIT and press Enter.
  790.  
  791.   SLEEP n
  792.     Creates a delay of n seconds.
  793.  
  794.     Example:  SLEEP 10
  795.  
  796.   X10SENDCMD "xx", "yy"
  797.     Send an X10 command.  The first parameter is the housecode and unitcode
  798.     to send, the second parameter is the command.
  799.  
  800.     Commands can be one of the following:
  801.  
  802.       ON
  803.       OFF
  804.  
  805.     Example:  X10SENDCMD "E4", "ON"
  806.  
  807.           Will turn on the X10 Module(s) with housecode "E" and unitcode
  808.           "4".
  809.  
  810.     See Also: SENDCMD
  811.  
  812.   X10SENDMCMD "x", "yy", nn
  813.     Send multiple X10 commands.  The first parameter is the housecode and
  814.     unitcode, the second parameter is the command, and the third parameter
  815.     is the number of times to send the command.
  816.  
  817.     Commands can be one of the following:
  818.  
  819.       DIM
  820.       BRI
  821.  
  822.     Example:  X10SENDMCMD "J2", "DIM", 5
  823.  
  824.           Will send 5 DIM commands to the X10 module(s) with the
  825.           housecode "J" and unitcode "2".
  826.  
  827.     See Also: SENDMCMD
  828.  
  829.   X10SENDUNIT "xx"
  830.     This command sends only a unit code.  The first and only parameter is
  831.     the housecode/unitcode.  This command is useful in conjunction
  832.     with the X10SENDFUNC and X10SENDMFUNC commands to control multiple
  833.     devices simultaneously.
  834.  
  835.     Example:  X10SENDUNIT "A12"
  836.           X10SENDUNIT "A13"
  837.  
  838.           X10SENDFUNC "A", "ON"
  839.           X10SENDMFUNC "A", "DIM", 5
  840.  
  841.           This example will send 5 DIMBRI commands to modules on
  842.           housecode A, units 12 and 13.
  843.  
  844.     See Also: SENDUNIT
  845.  
  846.   X10SENDFUNC "x", "yy"
  847.     This command sends function codes.  The first parameter is the housecode
  848.     to use, the second is the command to send.  Use this command in
  849.     conjunction with X10SENDUNIT to control multiple units simultaneously.
  850.  
  851.     Commands can be one of the following:
  852.  
  853.       ON
  854.       OFF
  855.       AUOFF   - all units off
  856.       ALON    - all lights on
  857.       ALOFF   - all lights off
  858.  
  859.     Example:  See X10SENDUNIT example.
  860.  
  861.     See Also:  SENDFUNC
  862.  
  863.   X10SENDMFUNC "x", "yy", z
  864.     This command sends multiple function codes.  The first parameter is
  865.     the housecode, the second is the command, the third is the number of
  866.     times to send the command.  Use this command in conjunction with
  867.     X10SENDUNIT to control multiple units simultaneously.
  868.  
  869.     Commands can be one of the following:
  870.  
  871.       DIM
  872.       BRI
  873.  
  874.     Example:  See X10SENDUNIT example.
  875.  
  876.     See Also:  SENDMFUNC
  877.  
  878.  
  879.   SENDCMD
  880.   SENDMCMD
  881.   SENDUNIT
  882.   SENDFUNC
  883.   SENDMFUNC
  884.     These commands are similar to the X10xxxxx commands listed above, but
  885.     accept the event names instead of housecode/unitcode strings.  This
  886.     is handy for naming your devices, instead of having to remember their
  887.     X-10 addresses.  It is much easier to remember "BEDROOMLIGHT" instead
  888.     of "J12".
  889.  
  890.     Example:   define module CEILINGFAN type X10 { LampModule E8 }
  891.  
  892.            sendcmd CEILINGFAN, "ON"
  893.  
  894.  
  895.   IRSEND "xxxxxx"  (Registered version only)
  896.  
  897.     This command is for sending commands to your infra-red interface.
  898.  
  899.     The commands you send relate directly to the buttons on the one-for-all
  900.     remote control attached to the serial port.  The commands are put in
  901.     the string just as they are labeled on the remote, with the following
  902.     exceptions:
  903.  
  904.       CHUP  = Channel Up
  905.       CHDN  = Channel Down
  906.       VOLUP = Volume Up
  907.       VOLDN = Volume Down
  908.       REW   = Rewind ( < )
  909.       FREW  = Fast Rewind ( << )
  910.       FFWD  = Fast Forward ( >> )
  911.  
  912.     Examples:
  913.  
  914.       IRSend "AMP VOLUP VOLUP VOLUP"
  915.       IRSend "VCR PLAY"
  916.  
  917.  
  918.   The following functions are supported in HAP-BASIC:
  919.  
  920.    ABS(x)         - returns absolute value of x
  921.    ASC(x$)        - returns ASCII code of first char in string x$
  922.    LEN(x$)        - returns the length of x$ in bytes
  923.    POS(0)         - returns current cursor column
  924.    VAL(x$)        - returns the value of X$ (converts text to numeric)
  925.  
  926.    CHR$(x)        - returns character of ASCII value x
  927.    LEFT$(x$,n)    - returns the left 'n' characters of x$
  928.    RIGHT$(x$,n)   - returns the right 'n' characters of x$
  929.    MID$(x$,n[,m]) - returns portion of x$ starting at n for m bytes
  930.    LTRIM$(x$)     - returns trimmed string (removes leading spaces)
  931.    RTRIM$(x$)     - returns trimmed string (removes trailing spaces)
  932.    SPACE$(n)      - returns a string consisting of 'n' spaces
  933.  
  934.    TOLOWER$(x$)   - returns string 'x$' but converted to lower case
  935.    TOUPPER$(x$)   - returns string 'x$' but converted to upper case
  936.  
  937.   The following functions are extensions to the BASIC language:
  938.  
  939.    EVENT_AVAIL(0) --  Returns a handle to an event that needs processing.
  940.  
  941.  
  942.    The following Variables are processed specially by the interpreter.
  943.    Note that the variables can be read from or written to unless otherwise
  944.    specified.
  945.  
  946.    CSRLIN         --  Read only.. Returns the current line (row) that
  947.               the cursor is on
  948.    DATE$          --  Read only.. Returns system date in format MM-DD-YYYY
  949.    TIME$          --  Read only.. Returns system time in format HH:MM:SS
  950.  
  951.    INKEY$         --  Returns keystroke, or NULL if no keystroke available
  952.  
  953.    SYS_CASESENS   --  Set this to true (1) for string variable compares to
  954.               be case sensitive, false (0) otherwise.  Default is
  955.               true (1), as this is BASIC's normal mode.
  956.  
  957.    SYS_VERSION$   --  Version number of the software, read only
  958.  
  959.  
  960.   ------------------------------------------------------------------------
  961.   Programming tips
  962.   ------------------------------------------------------------------------
  963.  
  964.   The general structure of an automation program is a follows:
  965.  
  966.   <define modules>
  967.  
  968.   <define events>
  969.  
  970.   <loop>
  971.     EVENT_CHECK
  972.     event = EVENT_AVAIL(0)
  973.  
  974.     if event = xxxxx then gosub yyyyy
  975.   <end loop>
  976.  
  977.   <event processor subroutines>
  978.  
  979.  
  980.  
  981.   Many things can be added to the structure to provide screen output,
  982.   keyboard handling, etc.  It all depends on what you need.
  983.  
  984.   The following tips are items that we found helpful while programming
  985.   our automation system:
  986.  
  987.   1)  When developing an event processor, specify a key on the PC keyboard
  988.       that you can hit to simulate the event.  For instance, if you are
  989.       developing a WAKEUP event that triggers at 6:00 each morning during
  990.       the week, it is not practical to make a change, then wait till 6:00
  991.       the next morning to see if it works.  Either use the INKEY$ function
  992.       to watch for a keypress, or create a 'test event' that waits for an
  993.       X10 code, and dispatch those to your WAKEUP event processor.
  994.  
  995.   2)  Use the supplied example scripts as a basis for yours.  They range
  996.       from easy to complicated.
  997.  
  998.   3)  Any suggestions you have to make this product more usable are
  999.       always considered and are helpful to the development of the product.
  1000.       Our BBS is the best source for correspondence.
  1001.  
  1002.   ------------------------------------------------------------------------
  1003.   X10 system caveats
  1004.   ------------------------------------------------------------------------
  1005.   Darn.  Now everything is working good, but some things just can't be
  1006.   done.  These are some of the issues that we came across, and how they
  1007.   are dealt with.
  1008.  
  1009.   - X10 is unable to start at specific brightness.
  1010.  
  1011.     A true limitation of the X10 protocol.  It is not possible to tell a
  1012.     light to turn on at a specific brightness level.  The light must be
  1013.     brought on full, then brought down to the desired level.  This is really
  1014.     annoying during nice 'movie viewing' scripts.  You press a button for
  1015.     an intermission mode, and BLAM! the lights in the house come on and
  1016.     fry you and your guest's eyes.
  1017.  
  1018.     Solution:
  1019.     Pick out the lights that you might want to come on later, and
  1020.     dim them to zero.  Then they can be brought up from zero, and not wake
  1021.     everyone up so suddenly.  It is not recommended to always turn lights
  1022.     off this way, as the unit is still active and pulling power.  This is
  1023.     definitely not recommended for variable speed motor appliances (ceiling
  1024.     fans).
  1025.  
  1026.   - Light status synchronization.
  1027.  
  1028.     Another limitation of the X10 protocol.  There is no way to querry
  1029.     a light to see if it is on or off.  If the light is turned on from
  1030.     the switch itself, the computer has no way of knowing that it's status
  1031.     has changed.  This is mostly a problem when you go to issue a DIM or
  1032.     BRIGHT command, because if the light is off, and receives a DIM or
  1033.     BRIGHT command, it first turns on at full brightness.  Or, if the light
  1034.     is totally dimmed to where it is not on, an ON command will not affect
  1035.     it, since it's status is already ON.
  1036.  
  1037.     Solution:
  1038.     1) Use in-wall transmitters instead of normal switches.  These units
  1039.        send actual X10 Commands.
  1040.     2) Use the handheld remotes to turn lights on and off.
  1041.     3) Force the status to be known by first turning the light off before
  1042.        issuing the ON command followed by DIM commands.
  1043.  
  1044.   - One-way communications
  1045.  
  1046.     Not only is there no way to know if a unit is on or off, there is no
  1047.     way to know if a command you have issued has actually gotten to the unit
  1048.     without verifying it physically.
  1049.  
  1050.   - TV/Stereo/VCR power modes
  1051.  
  1052.     Most audio/video equipment does not have specific on/off switches, but
  1053.     rather a power switch that toggles the power.  Therefore, when you
  1054.     try to turn equipment on, and it is already on, you end up turning it
  1055.     off.  Sigh.
  1056.  
  1057.     Solution:
  1058.     Don't use the power buttons on your existing remotes.  Use X10 commands
  1059.     to control your equipment.  It works nicer anyway, once it is set up.
  1060.  
  1061.   - Signal suppression
  1062.  
  1063.     Sometimes, good quality surge supression devices will block X10 signals
  1064.     over the power lines.  Bummer.  If you are having problems with devices
  1065.     not turning on or off, keep this fact in mind.  Also try relocating the
  1066.     X10 receiver as sometimes this helps.
  1067.  
  1068.   ------------------------------------------------------------------------
  1069.   Planned Enhancements
  1070.   ------------------------------------------------------------------------
  1071.   These are items that we will be adding, but didn't make this release.
  1072.   Any suggestions are greatly appreciated for future versions.
  1073.  
  1074.   These items are not a definitive list, and certainly not a complete
  1075.   list, but represent changes we would like to make soon.
  1076.  
  1077.   - Twilight calculator so the system knows the daylight level based on
  1078.     latitude, longitude, day of year and current time.
  1079.  
  1080.   - Further extensions to the HAP-BASIC language.
  1081.  
  1082.   - Comprehensive error checking for the HAP-BASIC interpreter.
  1083.  
  1084.   - Support for additional hardware, including A/D-D/A and relay boards.
  1085.  
  1086.   ------------------------------------------------------------------------
  1087.   Important things to think about
  1088.   ------------------------------------------------------------------------
  1089.   Home automation is fun, but keep the following points in mind:
  1090.  
  1091.   Don't control things like curling irons, power tools, etc.  When
  1092.   designing your home automation system, remember that things can go wrong,
  1093.   so don't put your home or lives in jeapordy by being careless.
  1094.  
  1095.   ALWAYS CONSIDER WHAT WOULD HAPPEN IF SOMETHING DID NOT WORK RIGHT WHEN
  1096.   DESIGNING YOUR AUTOMATION SYSTEM.
  1097.  
  1098.   It is possible for other people to control your X10 devices, either via
  1099.   power lines (you have an outside power receptacle, right?), or with the
  1100.   remotes.  Most of the remotes are on the same frequency.  Also, a house
  1101.   that is close to yours may receive your X10 codes through the power lines.
  1102.   If this is a problem, arrange with your neighbors which housecodes to use.
  1103.   Try not to configure your system so that you control his jacuzzi pump
  1104.   with your lightswitch.  Very annoying.
  1105.  
  1106.   Don't control security sensitive things like garage doors, entry doors,
  1107.   etc. with X10.  There are ways to make it more secure, but we still don't
  1108.   recommend it without a lot of thought.  Think about the previous paragraph.
  1109.  
  1110.   ------------------------------------------------------------------------
  1111.   Troubleshooting
  1112.   ------------------------------------------------------------------------
  1113.  
  1114.   When things don't work, I usually find that a troubleshooting guide
  1115.   answers all questions except the ones I have.  This may be the case
  1116.   here also, but look anyway, because the answer just might be here.
  1117.  
  1118.   1)  Lights are not going on when X10 codes are sent.
  1119.  
  1120.       First, check the connection to the TW-523 interface.  There is a
  1121.       status LED on the interface that flashes when X10 codes are sent
  1122.       OR received.  If the LED is flashing but the lights are not
  1123.       changing, you may need to link the two phases of your power together.
  1124.       Try using standard X10 remotes and receivers in the same power outlet
  1125.       to diagnose this further.  If needed, an X10 signal bridge is
  1126.       available to solve the problem.
  1127.  
  1128.       Also, check your house for surge suppression.  Sometimes, surge
  1129.       supressors can block the X10 codes, as they look just like noise
  1130.       on the power line.
  1131.  
  1132.   More in the next release...but you are welcome to call our BBS with
  1133.   questions if you need more help.
  1134.  
  1135.  
  1136.  
  1137.  
  1138.  
  1139.  
  1140.  
  1141.  
  1142.